import subprocess

result = subprocess.run(
    ['echo', '$PATH'],  # 注意$PATH并没有展开
    capture_output=True,
    encoding='utf-8'
)

result.check_returncode()
print(result.stdout)
